﻿#ifndef CIRT_LUA_H
#define CIRT_LUA_H
#include "dmos.h"
extern "C"
{
#include "lua54/lua.h"
#include "lua54/lauxlib.h"
}
#include "dmthread.h"

static void stackDump(lua_State* L)
{
    int i;
    int top=lua_gettop(L);
    for(int i=1;i<=top;i++)
    {
        int t=lua_type(L,i);
        switch (t) {
        case LUA_TSTRING:
        {
            std::string res = lua_tostring(L,i);
            std::cout<< res <<std::endl;
        }
        break;
        case LUA_TBOOLEAN:
        {
            std::string res=lua_toboolean(L,i) ? "true":"false";
            std::cout<< res << std::endl;
        }
        break;
        case LUA_TNUMBER:
            std::cout<< lua_tonumber(L,i)<<std::endl;
            break;
        default:
            std::cout<< lua_typename(L,t)<<std::endl;
            break;
        }
    }
}





namespace CIRT {

class cirt_lua
{
public:
    cirt_lua();

    bool parserProgram(std::string pro);

    void runlua();
private:
    void PrintLuaError(lua_State* L,int sErr);
private:
    std::string _mpro;
    lua_State* Lu;

};

}
#endif // CIRT_LUA_H
